﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GalaktikaERPHelper.AtlantisDataTypeConversions
{
    using GalaktikaERPHelper.AtlantisDataTypeConversions.Extensions;

    public static class AtlConvert
    {
        public static DateTime AtlDateTimeToDateTime(int date, int time)
        {
            if (date == 0)
                return DateTime.MinValue;
            if (time == 0)
                return date.ToDateTime();

            var _date = date.IntToBytes();
            var _time = time.IntToBytes();
            return new DateTime(
                (new byte[2] { _date[0], _date[1] }).ToInt(),
                _date[2].ToInt(),
                _date[3].ToInt(),
                _time[0].ToInt(),
                _time[1].ToInt(),
                _time[2].ToInt(),
                _time[3].ToInt()*10
                );
        }
        public static DateTime AtlDateToDateTime(int date)
        {
            return date.ToDateTime();
        }
        public static string ByteToHexString(byte[] value)
        {
            return value.ToHexString();
        }
        public static byte[] HexStringToByte(string value)
        {
            return value.ToComp();
        }
        public static long ByteToLong(byte[] value)
        {
            return value.ToLong();
        }
        public static byte[] LongToByte(long value)
        {
            return value.ToComp();
        }

    }
}
